package algorithm_demo.demo05;

/**
 * 菲波那切数列
 * 1,1,2,3,5,8....
 * 求第N项
 * 递推公式：f(N) = f(N-1) + f(N-2)
 *
 * @author Api
 * @date 2023/3/12 1:16
 */
public class Code09_FibonacciSequence {
    //解题思路：f(N) = f(N-1)+f(N-2)


    public static int process(int n) {
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 1;
        }
        return process(n - 1) + process(n - 2);
    }

    public static void main(String[] args) {
        int process = process(10);
        System.out.println(process);
    }
}
